//
//  VKServerXYListController.m
//  V-Learn
//
//  Created by liubo on 2019/2/15.
//  Copyright © 2019 yxk. All rights reserved.
//

#import "VKServerXYListController.h"
#import "VKServerXYListCell.h"
#import "VKServerXYListModel.h"
#import "VKServerXYController.h"
@interface VKServerXYListController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *dataArray;

@end

@implementation VKServerXYListController

-(NSMutableArray *)dataArray{
    if (_dataArray == nil) {
        _dataArray = [[NSMutableArray alloc]init];
    }
    return _dataArray;
}
-(UITableView *)tableView{
    if (_tableView == nil) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen cz_screenWidth], [UIScreen cz_screenHeight] - LBNAVBAR_HEIGHT) style:UITableViewStylePlain];
        _tableView.tableFooterView = [UIView new];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.rowHeight = 60;
//        _tableView.estimatedRowHeight = 500; /// 预估行高
        [self.view addSubview:_tableView];
    }
    return _tableView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"服务协议";
    self.view.backgroundColor = [UIColor whiteColor];
    [self setupData];

    [self tableView];
}
- (void)setupData{
    
    NSMutableArray *array = [[NSMutableArray alloc]init];
    
    [array addObject:@{@"title":@"用户注册协议"}];
    [array addObject:@{@"title":@"报名课程协议"}];
    [array addObject:@{@"title":@"分销协议"}];
    [array addObject:@{@"title":@"分销提现协议"}];
    
    for (NSDictionary *dic in array) {
        VKServerXYListModel *model = [VKServerXYListModel mj_objectWithKeyValues:dic];
        [self.dataArray addObject:model];
    }
    
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataArray.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    VKServerXYListCell *cell = [VKServerXYListCell cellWithTableView:tableView];
    cell.model = self.dataArray[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    VKServerXYController *xy = [[VKServerXYController alloc]initWithType:[NSString stringWithFormat:@"%ld",indexPath.row + 1]];
    /**
     if (model.row == 0) {
     _titleLabel.text = @"一、总则";
     }else if (model.row == 1){
     _titleLabel.text = @"二、服务内容";
     }else if(model.row == 2){
     _titleLabel.text = @"三、用户账号";
     }else if (model.row == 3){
     _titleLabel.text = @"四、特别注意";
     }
     */
    if (indexPath.row == 0) {
        xy.title = @"用户注册协议";
        xy.OterString = @"一、总则";
    }else if (indexPath.row == 1){
        xy.title = @"报名课程协议";
        xy.OterString = @"二、服务内容";
    }if (indexPath.row == 2) {
        xy.title = @"分销协议";
        xy.OterString = @"三、用户账号";
    }else if (indexPath.row == 3){
        xy.title = @"分销提现协议";
        xy.OterString = @"四、特别注意";
    }
    [self.navigationController pushViewController:xy animated:YES];
}

@end
